﻿

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Collections;


namespace Lib.CommonForm
{
    public class tbl_Parameters_Info : Standard_Info
    {
        public string DomainCode { get; set; }
        public string ItemCode { get; set; }
        public string ItemValue { get; set; }
        public int ItemOrder { get; set; }
        public bool IsActive { get; set; }
    }
    public class tbl_Parameters_CompanyInfo : Standard_Info
    {
        public string CompanyName { get; set; }
        public string Phone { get; set; }
        public string Address { get; set; }
        public string Email { get; set; }
        public string Website { get; set; }
        public string Fax { get; set; }
        public string Contact { get; set; }
        public string Trades { get; set; }
    }
    public class tbl_Parameters_Controller
    {
        #region "Contructor"

        private static tbl_Parameters_Controller _instance;

        protected tbl_Parameters_Controller() { }

        protected void Dispose()
        {
            _instance = null;
        }

        private static object _syncLock = new object();

        public static tbl_Parameters_Controller Instance()
        {
            if (_instance == null)
            {
                lock (_syncLock)
                {
                    if (_instance == null)
                        _instance = new tbl_Parameters_Controller();
                }
            }
            return _instance;
        }

        #endregion

        public DataSet GetAll()
        {
            return DataConnect.ExecuteDataset("SELECT * FROM tbl_Parameters");
        }

        public bool Delete(string DomainCode, string ItemCode)
        {
            bool retVal = false;

            return retVal;
        }

        public bool IsExist(string DomainCode, string ItemCode)
        {
            bool retVal = false;

            return retVal;

        }

        public bool Save(tbl_Parameters_Info i)
        {
            return (DataConnect.ExecuteNonQuery("prc_Parameters_Appened", i.DomainCode, i.ItemCode, i.ItemValue, i.ItemOrder) > 0);
        }

        public tbl_Parameters_Info GetInfo(string DomainCode, string ItemCode)
        {
            tbl_Parameters_Info retVal = null;
            DataTable dt = null;
            dt = DataConnect.ExecuteDataset("prc_Parameters_GetInfo", DomainCode, ItemCode).Tables[0];
            if (dt != null)
                foreach (DataRow dr in dt.Rows)
                {
                    retVal = new tbl_Parameters_Info();
                    retVal.FillDataProperty(dr);
                }

            return retVal;
        }
        public tbl_Parameters_CompanyInfo GetInfo()
        {
            tbl_Parameters_CompanyInfo retVal = null;

            DataTable dtCompany = CompanyGetAll();

            DataTable dt = Globals.ChangeRowsToColumns(dtCompany);

            if (dt != null)
                foreach (DataRow dr in dt.Rows)
                {
                    retVal = new tbl_Parameters_CompanyInfo();
                    retVal.FillDataProperty(dr);
                }

            return retVal;
        }
        public DataTable CompanyGetAll()
        {
            return DataConnect.ExecuteDatatable("prc_Parameters_CompanyGetAll");
        }
    }
}
